<template>
  <van-popup v-model="showBox" :closed="close">
    <div class="box">
      <div class="title">
        {{ title }}
      </div>
      <div class="desc" v-html="desc"></div>
      <van-row type="flex" class="btn">
        <van-button type="default" @click="$emit('input', false)">
          {{ cancelText }}
        </van-button>
        <van-button type="primary" @click="$emit('submit')">
          {{ okText }}
        </van-button>
      </van-row>
    </div>
  </van-popup>
</template>
<script>
export default {
  props: {
    value: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ""
    },
    desc: {
      type: String,
      default: ""
    },
    okText: {
      type: String,
      default: "确定"
    },
    cancelText: {
      type: String,
      default: "取消"
    }
  },
  computed: {
    showBox: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("input", val);
      }
    }
  },
  methods: {
    close() {
      this.$emit("close");
    }
  }
};
</script>

<style lang="scss" scoped>
.van-popup--center {
  border-radius: 10px;
}
.box {
  width: 4.5rem;
  padding-top: 15px;
  font-size: 16px;
  .title {
    padding: 0 15px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
  }
  .desc {
    margin-bottom: 15px;
    padding: 0 15px;
    ::v-deep .red {
      color: red;
    }
    ::v-deep .padding {
      padding-right: 0.5em;
    }
  }
  .btn {
    button {
      width: 50%;
      display: block;
    }
  }
}
</style>
